﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using COFE.Core;
using COFE.Core;
using COFE.Core.Lister;

namespace COFE.Core.Profile
{
    public enum VolumeAccessMode : int
    {
        None = 0,
        List = 0x1,
        Read = 0x2,
        Write = 0x3,
        Execute = 0x4,
        All = List | Read | Write | Execute
    }


    /// <summary>
    /// Provide information about a IDirectoryLister.
    /// </summary>
    public interface IVolume
    {
        /// <summary>
        /// Factory used to construct this entries.
        /// </summary>
        string FactoryKey { get; }

        /// <summary>
        /// ID of this entries.
        /// </summary>
        string ListerKey { get; }

        ///// <summary>
        ///// Return access mode of this directory volume.
        ///// </summary>
        //VolumeAccessMode AccessMode { get; }

        /// <summary>
        /// Return the DirectoryLister to use.
        /// </summary>
        IDirectoryLister DirectoryLister { get; }

        /// <summary>
        /// Return the Original DirectoryLister to use.
        /// </summary>
        IDirectoryLister CacheDirectoryLister { get; }

        /// <summary>
        /// Return the DirectoryController to use.
        /// </summary>
        IDirectoryController DirectoryController { get; }

        /// <summary>
        /// Return the StreamProvider to use.
        /// </summary>
        IStreamProvider StreamProvider { get; }

        /// <summary>
        /// Return the default access mode of this volume.
        /// </summary>
        VolumeAccessMode AccessMode { get; }
    }

    public static class IVolumeExtension
    {
        public static bool IsPrimaryDirectoryLister(this IVolume volume) { return volume.DirectoryLister is IPrimaryDirectoryLister; }
        public static bool IsSecondaryDirectoryLister(this IVolume volume) { return volume.DirectoryLister is ISecondaryDirectoryLister; }
        public static string GetArgs(this IVolume volume) { 
            return COFEShared.VolumeRegistrar.Factories[volume.FactoryKey]
                .Recycle(volume.DirectoryLister); }
        
    }

}
